﻿namespace BlamanticUI.Components;

using Abstractions;

using ComponentBuilder;
using ComponentBuilder.Abstrations;

/// <summary>
/// Represents a base class of header component.
/// </summary>
public abstract class HeaderComponentBase : BlazorChildContentComponentBase, IHasUIComponent, IHasIcon, IHasAttatched, IHasDivider, IHasInverted, IHasFloated, IHasHorizontalAlignment, IHasColor
{
    /// <summary>
    /// Initializes a new instance of the <see cref="HeaderComponentBase"/> class.
    /// </summary>
    /// <param name="number">title number, 1-6.</param>
    protected internal HeaderComponentBase(int number) : base()
    {
        Number = number;
    }

    /// <summary>
    /// Gets the number of header.
    /// </summary>
    protected internal int Number { get; }

    /// <summary>
    /// Get h{number} for tag name.
    /// </summary>
    protected override string TagName => $"h{Number}";

    /// <summary>
    /// Gets or sets a value indicating whether a divider between components.
    /// </summary>
    /// <value>
    ///   <c>true</c> if has divider; otherwise, <c>false</c>.
    /// </value>
    [Parameter] [CssClass("dividing")] public bool Divider { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether display as blocked.
    /// </summary>
    /// <value>
    ///   <c>true</c> if blocked; otherwise, <c>false</c>.
    /// </value>
    [Parameter] [CssClass("block")] public bool Blocked { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether it is a sub-header.
    /// </summary>
    /// <value>
    ///   <c>true</c> if [sub header]; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool SubHeader { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether the content of child can render <see cref="Icon" /> component properly.
    /// </summary>
    /// <value>
    ///   <c>true</c> if icon; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Icon { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether attach to another.
    /// </summary>
    /// <value>
    ///   <c>true</c> if attached; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Attached { get; set; }
    /// <summary>
    /// Gets or sets the attach position in vertical.
    /// </summary>
    [Parameter] public VerticalPosition? AttachedVertical { get; set; }
    /// <summary>
    /// Gets or sets a value indicating whether adapted inverted background by parent component.
    /// </summary>
    /// <value>
    ///   <c>true</c> if adapted; otherwise, <c>false</c>.
    /// </value>
    [Parameter] public bool Inverted { get; set; }
    /// <summary>
    /// Gets or sets the float position.
    /// </summary>
    [Parameter] public HorizontalPosition? Floated { get; set; }
    /// <summary>
    /// Gets or sets the horizontal alignment of text.
    /// </summary>
    [Parameter] public HorizontalAlignment? HorizontalAlignment { get; set; }
    /// <summary>
    /// Gets or sets the color.
    /// </summary>
    [Parameter] public Color? Color { get; set; }
    protected override void BuildCssClass(ICssClassBuilder builder)
    {
        builder.Append("sub", SubHeader).Append("header");
    }
}
